package com.android.plc.ui.control;

import android.content.Context;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.Button;

import com.android.plc.CONST.COMMAND;
import com.android.plc.CONST;
import com.android.plc.R;

public class BackAudioControl extends TVPlayControl implements OnClickListener
{
	private static final int OFFSET_3 = 3;
	private static final int OFFSET_4 = 4;

	private Button mMp3Btn;
	private Button mFMBtn;
	private Button mCDBtn;
	private Button mAUXBtn;

	public BackAudioControl(Context context, ViewGroup view, int res_id)
	{
		super(context, view, res_id);
	}

	public BackAudioControl(Context context, ViewGroup view)
	{
		super(context, view, R.layout.control_backmusic);
	}

	@Override
	public void initView(ViewGroup view)
	{
		super.initView(view);

		mMp3Btn = (Button) view.findViewById(R.id.btn_mp3);
		mFMBtn = (Button) view.findViewById(R.id.btn_fm);

		mCDBtn = (Button) view.findViewById(R.id.btn_cd);
		mAUXBtn = (Button) view.findViewById(R.id.btn_aux);

		mMp3Btn.setOnClickListener(this);
		mFMBtn.setOnClickListener(this);
		mCDBtn.setOnClickListener(this);
		mAUXBtn.setOnClickListener(this);
	}

	public void onClick(View v)
	{
		super.onClick(v);
		switch (v.getId())
		{
		case R.id.btn_mp3:
			sendCommand(OFFSET_3, COMMAND.ON, CONST.DEF_DATA, 0);
			break;
		case R.id.btn_fm:
			sendCommand(OFFSET_3, COMMAND.OFF, 0, 0);
			break;
		case R.id.btn_cd:
			sendCommand(OFFSET_4, COMMAND.ON, CONST.DEF_DATA, 0);
			break;
		case R.id.btn_aux:
			sendCommand(OFFSET_4, COMMAND.OFF, 0, 0);
			break;
		default:
			break;
		}

	}
}
